// events/auth-events.ts
export const AUTH_EVENTS = {
  REDIRECT_NEEDED: 'auth:redirect-needed',
} as const

export interface RedirectEventDetail {
  path: string
  from?: string
}

// 触发重定向事件
export const emitRedirectEvent = (detail: RedirectEventDetail) => {
  if (typeof window !== 'undefined') {
    const event = new CustomEvent(AUTH_EVENTS.REDIRECT_NEEDED, { detail })
    window.dispatchEvent(event)
  }
}
